﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;

namespace PenguinForce.Levels
{
    [Serializable]
    public class Tile
    {

        public Tile(SpriteSheet textureList)
        {
            if (textureList != null)
            {
                Tile.m_textureList = textureList;
            }
        }

        public void Update(GameTime gameTime)
        {


        }

        public void Draw(GameTime gameTime, SpriteBatch sprite, float x, float y)
        {
            sprite.Draw(m_textureList.Texture, new Vector2(x, y), m_textureList.SourceRectangle((int)m_tileType), Color.White);
        }

        public void DrawBlendTexture(GameTime gameTime, SpriteBatch sprite, float x, float y, Tile.RockBlend blend, SpriteSheet rockTextureList)
        {
            sprite.Draw(rockTextureList.Texture, new Vector2(x, y), rockTextureList.SourceRectangle((int)blend + 6), Color.White);
            //sprite.Draw(rockTextureList[(int)blend], new Vector2(x, y), Color.White);
        }

        public void DrawBlendTexture(GameTime gameTime, SpriteBatch sprite, float alpha, Tile.RockBlend blend, SpriteSheet rockTextureList)
        {
            sprite.Draw(rockTextureList.Texture, m_location, rockTextureList.SourceRectangle((int)blend + 6), new Color(255, 255, 255, alpha));
            //sprite.Draw(rockTextureList[(int)blend], m_location, new Color(255, 255, 255, alpha));
        }

        public void Draw(GameTime gameTime, SpriteBatch sprite, float alpha)
        {
            sprite.Draw(m_textureList.Texture, m_location, m_textureList.SourceRectangle((int)m_tileType), new Color(255, 255, 255, alpha));

        }

        public float GetFriction()
        {
            return m_tileFriction[(int)m_tileType];

        }

        public float[] m_tileFriction = { 0.6f, 1.0f, 0.3f, 5.0f, 1.0f, 0.9f };

        public enum TileTypes
        {
            Ice,
            Rock,
            Sand,
            SlipperyIce,
            Hole,
            ThinIce
        }

        public enum RockBlend
        {
            RockLone,
            RockN,
            RockW,
            RockNW,
            RockE,
            RockNE,
            RockWE,
            RockWNE,
            RockS,
            RockNS,
            RockSW,
            RockSWN,
            RockSE,
            RockNES,
            RockESW,
            Rock
        }

        public TileTypes m_tileType;

#if !XBOX360
        [NonSerialized]
#endif
        public static SpriteSheet m_textureList;
        public Vector2 m_location;

    }
}